package com.zack.algorithm.trie;

/**
* email: miao.du@shuruitech.com
* author: zack
**/
import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class TrieNode implements Serializable {

    private static final long serialVersionUID = 5324865847956488115L;

    public int preFixFreq;

    public LinkedList<TrieNode> childNodes;

    public List<String> typeList = new ArrayList<>();

    public TrieNode fatherNode = null;

    public char nodeChar;

    public String wholeWord = "";

    public boolean isEnd;

    public String compactStr;

    public String getCompactStr() {
        return compactStr;
    }

    public void setCompactStr(String compactStr) {
        this.compactStr = compactStr;
    }

    public int getPreFixFreq() {
        return preFixFreq;
    }

    public void setPreFixFreq(int preFixFreq) {
        this.preFixFreq = preFixFreq;
    }

    public LinkedList<TrieNode> getChildNodes() {
        return childNodes;
    }

    public void setChildNodes(LinkedList<TrieNode> childNodes) {
        this.childNodes = childNodes;
    }

    public TrieNode getFatherNode() {
        return fatherNode;
    }

    public void setFatherNode(TrieNode fatherNode) {
        this.fatherNode = fatherNode;
    }

    public char getNodeChar() {
        return nodeChar;
    }

    public void setNodeChar(char nodeChar) {
        this.nodeChar = nodeChar;
    }

    public String getWholeWord() {
        return wholeWord;
    }

    public List<String> getTypeList() {
        return typeList;
    }

    public void setTypeList(List<String> cuiList) {
        this.typeList = cuiList;
    }

    public void setWholeWord(String wholeWord) {
        this.wholeWord = wholeWord;
    }

    public TrieNode(char c) {
        childNodes = new LinkedList<>();
        nodeChar = c;
        isEnd = false;
        preFixFreq = 0;
    }

    /**
     * @param c
     * @return
     */
    public TrieNode subNodes(char c) {
        if (null != childNodes) {
            for (TrieNode node : childNodes) {
                if (node.nodeChar == c) {
                    return node;
                }
            }
        }
        return null;
    }
}
